﻿// =================================================================== 
// 项目说明
//====================================================================
//   @Copy Right 2006-2008
// 文件：DataAccessFactory.cs
// 项目名称：


// 创建时间：2008-03-06
// 负责人：
// ===================================================================
using System;
using System.Reflection;
using CommonLib.ComMon;

namespace CRMMis.DALFactory
{
    /// <summary>
    /// 数据层工厂


    /// </summary>
    public class DataAccessFactory
    {
		//private static readonly string path = System.Configuration.ConfigurationSettings.AppSettings["DAL"];
        private static readonly string FilePath = BSconfig.GetConfig("CRMPath");
        private static readonly string DALNameSpace = BSconfig.GetConfig("DAL");

        public static object CreateObject(string ClassName)
        {
            string CacheKey = DALNameSpace + "." + ClassName;
            object objType = DataCache.GetCache(CacheKey);
            if (objType == null)
            {
                try
                {
                    objType = Assembly.Load(FilePath).CreateInstance(CacheKey);
                    DataCache.SetCache(CacheKey, objType);
                }
                catch { }

            }
            return objType;
        }

    }
}

